<?php

namespace App\Http\Controllers;
trait ApiResponse{


	/**
	 * 正确提示
	 *
     * @param $success
     * @param array $data
     * @param string $status
     * @return mixed
     */
	public function success($data, $status = "success") {
		return $this->status($status,$data,0);
	}

	/**
	 * 错误提示
	 *
     * @param $errors
     * @param array $data
     * @param string $status
     * @return mixed
     */
	public function errors($data, $status = "errors",$code = 100) {
		return $this->status($status,$data,$code);
	}

    /**
     * 错误提示
     *
     * @param $errors
     * @param  array  $data
     * @param  string  $status
     *
     * @return mixed
     */
    public function failure($status = "errors", $code = 100, $data = [])
    {
        return $this->status($status, $data, $code);
    }

 	/**
     * @param $status
     * @param array $data
     * @param null $code
     * @return mixed
     */
    public function status($status, $data, $code = null){
        $datas = [];
        $datas['ResponseStatus'] 	= $code;
        $datas['ResponseMsg'] 		= $status;
        $datas['datas'] 			= $data;
        return response()->json($datas);
    }
}
